```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单例设计模式：保障唯一实例的经典方案</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero-title {
            font-family: 'Noto Serif SC', serif;
            text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
        }
        .code-block {
            background-color: #2d3748;
            border-radius: 0.5rem;
            position: relative;
        }
        .code-block pre {
            color: #e2e8f0;
            overflow-x: auto;
            padding: 1.5rem;
            margin: 0;
            font-family: 'Courier New', Courier, monospace;
        }
        .code-block .copy-btn {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background-color: rgba(255,255,255,0.1);
            border: none;
            color: #e2e8f0;
            padding: 0.25rem 0.5rem;
            border-radius: 0.25rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .code-block .copy-btn:hover {
            background-color: rgba(255,255,255,0.2);
        }
        .feature-card {
            transition: transform 0.3s, box-shadow 0.3s;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .visualization {
            background-color: #f8fafc;
            border-radius: 0.5rem;
            padding: 2rem;
        }
        .hover-grow {
            transition: transform 0.2s;
        }
        .hover-grow:hover {
            transform: scale(1.02);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="relative bg-gradient-to-r from-blue-600 to-indigo-800 text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <span class="inline-block bg-white bg-opacity-20 px-3 py-1 rounded-full text-sm font-semibold mb-4">创建型设计模式</span>
            <h1 class="hero-title text-4xl sm:text-5xl md:text-6xl font-bold mb-6">单例设计模式：保障唯一实例的经典方案</h1>
            <p class="text-xl opacity-90 max-w-2xl mx-auto">确保系统核心组件唯一性的优雅解决方案，提升资源利用效率与代码可维护性</p>
            <div class="mt-10">
                <div class="inline-flex items-center space-x-4">
                    <div class="flex items-center">
                        <i class="fas fa-cubes mr-2"></i>
                        <span>唯一实例</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-globe mr-2"></i>
                        <span>全局访问</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>线程安全</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Introduction -->
        <section class="mb-16">
            <p class="text-lg leading-relaxed mb-6 text-gray-700">
                单例设计模式是一种常见的创建型设计模式，它确保一个类只能创建一个实例，并提供了全局访问点来获取该实例。在Java应用中，单例模式有着广泛的应用，从数据库连接池、日志记录器到线程池管理器，都可以从单例模式中受益。
            </p>
            
            <div class="visualization mb-12 hover-grow">
                <div class="mermaid">
                    flowchart TD
                        A[单例模式] --> B[特点]
                        A --> C[实现方式]
                        A --> D[应用场景]
                        
                        B --> B1[唯一实例]
                        B --> B2[全局访问点]
                        
                        C --> C1[饿汉式]
                        C --> C2[懒汉式]
                        C --> C3[双重检查锁]
                        C --> C4[静态内部类]
                        
                        D --> D1[资源共享]
                        D --> D2[实例控制]
                        D --> D3[全局访问]
                </div>
            </div>
        </section>

        <!-- Features Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2 flex items-center">
                <i class="fas fa-star mr-3 text-yellow-500"></i>
                <span>核心特点</span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="feature-card bg-white p-8 rounded-xl shadow-md">
                    <div class="text-blue-600 text-4xl mb-4">
                        <i class="fas fa-fingerprint"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">唯一实例</h3>
                    <p class="text-gray-600">
                        单例模式保证一个类仅有一个实例，避免了多次实例化造成的资源浪费，确保系统资源的高效利用。
                    </p>
                </div>
                
                <div class="feature-card bg-white p-8 rounded-xl shadow-md">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-door-open"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">全局访问点</h3>
                    <p class="text-gray-600">
                        通过提供一个全局访问方法，允许其他类在需要时获取该实例，简化了对象访问流程，提升了代码可维护性。
                    </p>
                </div>
            </div>
        </section>

        <!-- Use Cases -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2 flex items-center">
                <i class="fas fa-lightbulb mr-3 text-yellow-500"></i>
                <span>适用场景</span>
            </h2>
            
            <div class="space-y-6">
                <div class="bg-white rounded-lg shadow-sm overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-blue-100 p-3 rounded-lg">
                                <i class="fas fa-database text-blue-600"></i>
                            </div>
                            <div class="ml-4">
                                <h3 class="text-lg font-medium text-gray-900">资源共享</h3>
                                <p class="mt-1 text-gray-600">
                                    当多个对象需要共享同一个资源时，使用单例模式可以确保只有一个实例管理该资源，避免资源浪费。如数据库连接池、缓存系统等。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-lg shadow-sm overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-purple-100 p-3 rounded-lg">
                                <i class="fas fa-sliders-h text-purple-600"></i>
                            </div>
                            <div class="ml-4">
                                <h3 class="text-lg font-medium text-gray-900">控制实例数量</h3>
                                <p class="mt-1 text-gray-600">
                                    某些情况下，我们需要控制一个类只能拥有一个实例，如线程池、配置管理器、日志记录器等，确保系统行为的统一性。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-lg shadow-sm overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-green-100 p-3 rounded-lg">
                                <i class="fas fa-project-diagram text-green-600"></i>
                            </div>
                            <div class="ml-4">
                                <h3 class="text-lg font-medium text-gray-900">全局访问</h3>
                                <p class="mt-1 text-gray-600">
                                    当一个类的实例在多个地方都需要被访问时，单例模式提供了一个简便的方式来获取实例，减少代码耦合度。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Implementation -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2 flex items-center">
                <i class="fas fa-code mr-3 text-yellow-500"></i>
                <span>实现方式</span>
            </h2>
            
            <div class="space-y-12">
                <!-- 饿汉式 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800 flex items-center">
                        <span class="bg-blue-100 text-blue-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded">线程安全</span>
                        <span>1. 饿汉式</span>
                    </h3>
                    <p class="text-gray-600 mb-4">
                        在类加载时即创建实例，避免了多线程问题。简单直接，但可能在不需要实例时就预先创建，占用资源。
                    </p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">
                            <i class="fas fa-copy"></i>
                        </button>
                        <pre><code>public class Singleton {
    private static Singleton instance = new Singleton();

    private Singleton() {}

    public static Singleton getInstance() {
        return instance;
    }
}</code></pre>
                    </div>
                </div>
                
                <!-- 懒汉式 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800 flex items-center">
                        <span class="bg-yellow-100 text-yellow-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded">懒加载</span>
                        <span>2. 懒汉式</span>
                    </h3>
                    <p class="text-gray-600 mb-4">
                        实例只在第一次获取时创建，需要考虑线程安全问题。使用synchronized关键字保证线程安全，但性能较低。
                    </p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">
                            <i class="fas fa-copy"></i>
                        </button>
                        <pre><code>public class Singleton {
    private static Singleton instance;

    private Singleton() {}

    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}</code></pre>
                    </div>
                </div>
                
                <!-- 双重检查锁 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800 flex items-center">
                        <span class="bg-green-100 text-green-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded">高效线程安全</span>
                        <span>3. 双重检查锁</span>
                    </h3>
                    <p class="text-gray-600 mb-4">
                        使用双重检查锁机制，在多线程情况下保证线程安全，同时减少同步开销。需注意volatile关键字的使用，避免指令重排序问题。
                    </p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">
                            <i class="fas fa-copy"></i>
                        </button>
                        <pre><code>public class Singleton {
    private static volatile Singleton instance;

    private Singleton() {}

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}</code></pre>
                    </div>
                </div>
                
                <!-- 静态内部类 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800 flex items-center">
                        <span class="bg-purple-100 text-purple-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded">推荐方案</span>
                        <span>4. 静态内部类</span>
                    </h3>
                    <p class="text-gray-600 mb-4">
                        利用类加载机制保证懒加载且线程安全，实现方式简洁优雅，是Java单例模式推荐的实现方式之一。
                    </p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">
                            <i class="fas fa-copy"></i>
                        </button>
                        <pre><code>public class Singleton {
    private static class Holder {
        private static final Singleton INSTANCE = new Singleton();
    }

    private Singleton() {}

    public static Singleton getInstance() {
        return Holder.INSTANCE;
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Conclusion -->
        <section class="bg-blue-50 rounded-xl p-8">
            <div class="flex items-start">
                <div class="flex-shrink-0 text-blue-600 text-3xl mr-4">
                    <i class="fas fa-check-circle"></i>
                </div>
                <div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">总结与建议</h3>
                    <p class="text-gray-700">
                        以上这些实现方式各有优缺点，可以根据具体的使用场景选择适合的方式。使用单例模式可以提高代码的可维护性和性能，并确保某些资源在系统中唯一存在。在实际开发中，推荐优先考虑静态内部类的实现方式，它兼具线程安全和懒加载特性，实现简单可靠。
                    </p>
                    <p class="text-gray-700 mt-2">
                        通过了解单例设计模式的特点、适用场景和不同实现方式，开发者们可以更好地在项目中应用这一经典设计模式，提升代码的可读性和可维护性。
                    </p>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col items-center">
                <div class="text-xl font-medium text-white mb-2">技术小馆</div>
                <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors duration-200">
                    <i class="fas fa-external-link-alt mr-1"></i>
                    www.yuque.com/jtostring
                </a>
                <div class="mt-6 flex space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // 初始化Mermaid图表
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // 代码复制功能
        function copyCode(button) {
            const codeBlock = button.parentElement;
            const code = codeBlock.querySelector('pre code').innerText;
            navigator.clipboard.writeText(code).then(() => {
                const originalIcon = button.innerHTML;
                button.innerHTML = '<i class="fas fa-check"></i>';
                setTimeout(() => {
                    button.innerHTML = originalIcon;
                }, 2000);
            });
        }
    </script>
</body>
</html>
```